<template>
	<view class="content">
		<view class="cont-item" v-for="(item,index) in dataArr" @click="gotoDetail(item.id)">
			<view class="cover common-bg-img" :style="'background-image:url('+item.img+')'"></view>
			<view class="title">{{item.treeDetailNo}}</view>
			<view class="intro">{{item.title}}</view>
			<view class="other flexVerticle">
				<view class="bottomFlex">
					<text class="symbol">￥</text>
					<text class="price">{{item.money / 100.0}}</text>
				</view>
				<view class="btn-box centerFlex">认购</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				category: [],
				categoryIndex: 0,
				height: 0,
				page: 1,
				treeId: '',
				isLoad: true,
				dataArr: [],
				swiperCurrent: 0,
				swiperLength: 0,
				titleNViewBackground: '',
				carouselList: [],
			};
		},
		onShow() {

		},
		onLoad(options) {
			const that = this
			this.height = uni.getSystemInfoSync().windowHeight
			this.treeId = options.id
			that.getList();
		},
		onShareAppMessage() {
			const that = this
			return {
				title: '果王来了',
				imageUrl: 'https://shopmalling-asset.oss-cn-hangzhou.aliyuncs.com/share.jpg',
				path: '/pages/index/index'
			}
		},
		methods: {
			getList(reload) {
				const that = this
				if (reload) {
					this.page = 1
					this.isLoad = true
					this.dataArr = []
				}
				uni.showLoading({
					title: '正在加载'
				})

				that.$api.request('card', 'cardList', {
					page: that.page
				}, failres => {
					that.$api.msg(failres.errmsg)
					uni.hideLoading()
				}).then(res => {
					let data = res.data
					let arr = that.dataArr
					if (data.length > 0) {
						that.isLoad = true
					}
					data.forEach(item => {
						arr.push(item)
					})
					that.dataArr = arr
					uni.hideLoading()
				})
			},
			gotoDetail(id) {
				uni.navigateTo({
					url: '/pages/card/detail?id=' + id
				})
			},

			scrolltolower(e) {
				/* if(this.isLoad){
					this.isLoad = false
					let page = this.page;
					this.page = page+1
					this.getList()
				} */
			},

			naviageToPage(page) {
				uni.navigateTo({
					url: page
				})
			}

		},
	}
</script>

<style lang="less" scoped>
	.cont-item {
		margin-bottom: 20upx;
		padding: 40upx;
		background: rgba(255, 255, 255, 1);
		box-shadow: 0px 3upx 29upx 0px rgba(196, 196, 196, 0.35);
		border-radius: 20upx;

		.cover {
			width: 100%;
			height: 297upx;
		}

		.title {
			margin-top: 30upx;
			font-size: 30upx;
			color: #333333;
			font-weight: bold;
		}

		.intro {
			margin-top: 20upx;
			color: #666666;
			font-size: 24upx;
		}

		.other {
			margin-top: 30upx;
			color: #fa436a;

			.symbol {
				font-size: 26upx;
			}

			.price {
				font-size: 40upx;
				line-height: 1;
			}

			.btn-box {
				width: 186upx;
				height: 70upx;
				margin-left: auto;
				border: 4upx solid #fa436a;
				border-radius: 60upx;
				font-weight: bold;
				font-size: 30upx;
			}
		}
	}
</style>
